
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
locale-code
Advanced tools
Simple interface for ISO-639-1 language codes and ISO-3166-1-alpha-2 country codes.
npm install locale-code
Lookup language code from locale code
Lookup language english name by code
Lookup language native name by code
Check whether the given code is in the list of ISO-639-1
Get the array of the language objects by the given codes
Lookup country code from locale code
Lookup country name by code
Check whether the given code is in the list of ISO-3166-1-alpha-2
Check whether the given code is in the list of ISO-639-1 and ISO-3166-1-alpha-2
var LocaleCode = require('locale-code')
console.log(LocaleCode.getLanguageCode('en-US')); // 'en'
console.log(LocaleCode.getLanguageName('zh-CN')); // 'Chinese'
console.log(LocaleCode.getLanguageNativeName('zh-CN')); // '中文'
console.log(LocaleCode.getLanguageZhName('es-ES')); // '西班牙语'
console.log(LocaleCode.validateLanguageCode('en-US')); // true
console.log(LocaleCode.validateLanguageCode('bb-US')); // false
console.log(LocaleCode.getLanguages(['en-US','zh-CN']));
// [{code:'en-US', name:'English', nativeName:'English', zhName:'英语'}, {code:'zh-CN', name:'Chinese', nativeName:'中文', zhName:'中文'}]
console.log(LocaleCode.getCountryCode('en-US')); // 'US'
console.log(LocaleCode.getCountryName('en-US')); // 'United States'
console.log(LocaleCode.validateCountryCode('en-US')); // true
console.log(LocaleCode.validateCountryCode('en-ZZ')); // false
console.log(LocaleCode.validate('en-US')); // true
console.log(LocaleCode.validate('en_US')); // false
console.log(LocaleCode.validate('bb-XX')); // false
FAQs
locale code based on iso-639-1 and iso-3166-1
The npm package locale-code receives a total of 6,190 weekly downloads. As such, locale-code popularity was classified as popular.
We found that locale-code demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.